function fixedSidebar() {
    var side = $('.sidebar');
    var sideTop = side.offset().top + side.height();
    var h = $('.main').height() - side.height();
    var timer = 300;
    var fixStatus = function () {
        var winHeight = $(window).height();
        var scrollTop = $(document).scrollTop();
        var tempBottom = scrollTop + winHeight - sideTop;
        if (tempBottom > h) {
            tempBottom = h
        }
        ;
        if (scrollTop + winHeight > sideTop) {
            side.css({position: 'absolute', right: '0'}).stop(true).animate({top: tempBottom}, timer)
        } else {
            side.css({position: 'static', right: '0'}).stop(true).animate({top: 0}, timer)
        }
    };
    $(window).scroll(function () {
        fixStatus()
    });
    $(window).resize(function () {
        fixStatus()
    })
};
$(function(){
	fixedSidebar();
	slideSwitch();
})

$(function () {
    userGain();
    var icon = $('.yol-top dt a');
    icon.hover(function () {
        $(this).css({
            left: 0,
            top: 0,
            margin: 0,
            width: 151,
            height: 151,
            background: 'url(' + Util.config.imgfile + 'home/0' + (icon.index(this) + 1) + '.gif) no-repeat 0 0'
        })
    }, function () {
        $(this).attr('style', '')
    });
    var oApp = $('#yWebapp');
    var oClose = oApp.find('.close');
    oClose.click(function () {
        oApp.fadeOut('slow')
    })
});
function userGain() {
    var gain = $('#userGain');
    gain.wrap('<div class="gain-items"></div>').css('z-index', 9);
    setTimeout(function () {
        gain.animate({top: -300, right: 0}, 800).animate({top: -310, right: 0}, 800)
    }, 800)
};
function showPer() {
    var tar = $('.progre');
    tar.each(function () {
        var self = $(this);
        var per = self.find('.per');
        var div = per.find('div');
        var num = parseInt(per.attr('data-rel'));
        var interval;
        var count = 0;
        if (num == 100) {
            count = 100
        }
        ;
        var plus = function () {
            div.css({width: count + '%'});
            if (count == num || count == 100) {
                clearInterval(interval)
            }
            ;
            count++
        };
        interval = setInterval(plus, 5)
    })
};
function slideSwitch() {
    var stay = 6;
    var fade = 0.7;
    var msec = 1000;
    var timer = 400;
    var timeout;
    var prev = next = 0;
    var slider = $('#slider');
    var slideindex = true;
    var controls = false;
    var html = '';
    var term = slider.children('li');
    var len = term.length;
    slider.wrap('<div class="slider-items"></div>');
    if (slideindex) {
        if (len > 1) {
            html += '<div class="slider-index">';
            html += '<ol class="items">';
            for (var i = 1; i <= len; i++) {
                html += '<li ' + (i == 1 ? 'class="current"' : '') + '>' + '</li>'
            }
            ;
            html += '</ol>';
            html += '</div>'
        }
    }
    ;
    if (controls) {
        html += '<div class="slider-updown">';
        html += '<a href="#" class="button prev" data-rel="prev">prev</a>';
        html += '<a href="#" class="button next" data-rel="next">next</a>';
        html += '</div>'
    }
    ;
    slider.parent('.slider-items').wrap('<div class="slider-wrap"></div>').css({
        'position': 'relative',
        'overflow': 'hidden'
    }).after(html);
    var thumbCont = slider.parent().siblings('.slider-index');
    var thumb = thumbCont.find('li');
    var button = slider.parent().siblings('.slider-updown');
    slider.fadeIn();
    if (len == 1) {
        term.first().fadeIn()
    }
    ;
    button.find('.button').bind('click', function () {
        var self = $(this).attr('data-rel');
        if (self == 'prev') {
            if (prev == 0) {
                next = len - 1
            } else {
                next = prev - 1
            }
        } else if (self == 'next') {
            if (prev == len - 1) {
                next = 0
            } else {
                next = prev + 1
            }
        }
        ;
        autoPlay();
        return false
    });
    thumb.bind('click', function () {
        next = thumb.index($(this));
        clearTimeout(timeout);
        changePlay(next);
        if (next == len - 1) {
            next = 0
        } else {
            next++
        }
    });
    slider.hover(function () {
        clearTimeout(timeout)
    }, function () {
        if (len > 1) {
            timeout = setTimeout(autoPlay, stay * msec)
        }
    });
    var changePlay = function (next) {
        term.eq(prev).fadeOut(fade * msec);
        term.eq(next).fadeIn(fade * msec);
        thumb.removeClass('current');
        thumb.eq(next).addClass('current');
        if (typeof($('#userGain')[0]) != '') {
            $('#userGain').find('.opacity').css({opacity: term.eq(next).attr('data-opacity')})
        }
        ;
        prev = next
    };
    var autoPlay = function () {
        clearTimeout(timeout);
        changePlay(next);
        next = prev + 1;
        if (next >= len) {
            next = 0
        }
        ;
        timeout = setTimeout(autoPlay, stay * msec)
    };
    if (len > 1) {
        autoPlay()
    }
};
(function ($) {
    $.fn.extend({
        Scroll: function (opt, callback) {
            if (!opt)var opt = {};
            var _btnUp = $("#" + opt.up);
            var _btnDown = $("#" + opt.down);
            var timerID;
            var _this = this.eq(0).find("ul:first");
            var lineH = _this.find("li:first").height(), line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10), speed = opt.speed ? parseInt(opt.speed, 10) : 500;
            timer = opt.timer
            if (line == 0)line = 1;
            var upHeight = 0 - line * lineH;
            var scrollUp = function () {
                _btnUp.unbind("click", scrollUp);
                _this.animate({marginTop: upHeight}, speed, function () {
                    for (i = 1; i <= line; i++) {
                        _this.find("li:first").appendTo(_this);
                    }
                    _this.css({marginTop: 0});
                    _btnUp.bind("click", scrollUp);
                });
            }
            var scrollDown = function () {
                _btnDown.unbind("click", scrollDown);
                for (i = 1; i <= line; i++) {
                    _this.find("li:last").show().prependTo(_this);
                }
                _this.css({marginTop: upHeight});
                _this.animate({marginTop: 0}, speed, function () {
                    _btnDown.bind("click", scrollDown);
                });
            }
            var autoPlay = function () {
                if (timer)timerID = window.setInterval(scrollUp, timer);
            };
            var autoStop = function () {
                if (timer)window.clearInterval(timerID);
            };
            _this.hover(autoStop, autoPlay).mouseout();
            _btnUp.css("cursor", "pointer").click(scrollUp).hover(autoStop, autoPlay);
            _btnDown.css("cursor", "pointer").click(scrollDown).hover(autoStop, autoPlay);
        }
    })
})(jQuery);

/*
function setCookie(name, value, expire) {
    window.document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(Name) {
    var search = Name + "=";
    if (window.document.cookie.length > 0) { // if there are any cookies
        offset = window.document.cookie.indexOf(search);
        if (offset != -1) { // if cookie exists
            offset += search.length;
// set index of beginning of value
            end = window.document.cookie.indexOf(";", offset)
// set index of end of cookie value
            if (end == -1)
                end = window.document.cookie.length;
            return unescape(window.document.cookie.substring(offset, end));
        }
    }
    return null;
}
function register(name) {
    var today = new Date();
    var expires = new Date();
    expires.setTime(today.getTime() + 1000000*60*60*24);
    setCookie("hhedai-v3", name, expires);
}

function openWin() {
    var c = getCookie("hhedai-v3");
    if (c != null) {
        return;
    }

    register("hhedai-v3");
    var top_v2 = ($(window).height() - 608) / 2;
    var left_v2 = ($(window).width() - 870) / 2;
    $(".hhedai_v3").css({"top": top_v2, "left": left_v2});
    $('.hhedai_v3').css('display','block');
    $('.hhedai_z_v3').css('display','block');
}


openWin();
window.focus()

$('.hhedai_z_v3, .hhedai_v3').live('click',function(){
    $('.hhedai_z_v3').css('display','none');
    $('.hhedai_v3').css('display','none');
})
 */


$(document).ready(function (e) {
    var top = ($(window).height() - $("#detail").outerHeight()) / 2;
    var left = ($(window).width() - $("#detail").outerWidth()) / 2;
    $("#detail").css({"top": top, "left": left});
    $('.mzsm').click(function () {
        $('#detail').show();
        $('.pro_z').show();
    });
    $('.pro_z, .close').click(function () {
        $("#detail").slideUp();
        $('.pro_z').hide();
    })
    $('#detail').click(function () {
        return false;
    });
})
/*
 $(document).ready(function () {
 $("#scrollDiv").Scroll({line: 1, speed: 500, timer: 3000});
 fixedSidebar();
 });

var Speed_1 = 10; //�ٶ�(����)
var Space_1 = 20; //ÿ���ƶ�(px)
var PageWidth_1 = 260 * 2; //��ҳ���
var interval_1 = 5000; //��ҳ���ʱ��
var fill_1 = 0; //������λ
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1 = "right";
var Comp_1 = 0;
var AutoPlayObj_1 = null;
function GetObj(objName) {
    if (document.getElementById) {
        return eval('document.getElementById("' + objName + '")')
    } else {
        return eval('document.all.' + objName)
    }
}
function AutoPlay_1() {
    clearInterval(AutoPlayObj_1);
    AutoPlayObj_1 = setInterval('ISL_GoDown_1();ISL_StopDown_1();', interval_1)
}
function ISL_GoUp_1() {
    if (MoveLock_1)return;
    clearInterval(AutoPlayObj_1);
    MoveLock_1 = true;
    MoveWay_1 = "left";
    MoveTimeObj_1 = setInterval('ISL_ScrUp_1();', Speed_1);
}
function ISL_StopUp_1() {
    if (MoveWay_1 == "right") {
        return
    }
    ;
    clearInterval(MoveTimeObj_1);
    if ((GetObj('ISL_Cont_1').scrollLeft - fill_1) % PageWidth_1 != 0) {
        Comp_1 = fill_1 - (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1);
        CompScr_1()
    } else {
        MoveLock_1 = false
    }
    AutoPlay_1()
}
function ISL_ScrUp_1() {
    if (GetObj('ISL_Cont_1').scrollLeft <= 0) {
        GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft + GetObj('List1_1').offsetWidth
    }
    GetObj('ISL_Cont_1').scrollLeft -= Space_1
}
function ISL_GoDown_1() {
    clearInterval(MoveTimeObj_1);
    if (MoveLock_1)return;
    clearInterval(AutoPlayObj_1);
    MoveLock_1 = true;
    MoveWay_1 = "right";
    ISL_ScrDown_1();
    MoveTimeObj_1 = setInterval('ISL_ScrDown_1()', Speed_1)
}
function ISL_StopDown_1() {
    if (MoveWay_1 == "left") {
        return
    }
    ;
    clearInterval(MoveTimeObj_1);
    if (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1 - (fill_1 >= 0 ? fill_1 : fill_1 + 1) != 0) {
        Comp_1 = PageWidth_1 - GetObj('ISL_Cont_1').scrollLeft % PageWidth_1 + fill_1;
        CompScr_1()
    } else {
        MoveLock_1 = false
    }
    AutoPlay_1()
}
function ISL_ScrDown_1() {
    if (GetObj('ISL_Cont_1').scrollLeft >= GetObj('List1_1').scrollWidth) {
        GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft - GetObj('List1_1').scrollWidth
    }
    GetObj('ISL_Cont_1').scrollLeft += Space_1
}
function CompScr_1() {
    if (Comp_1 == 0) {
        MoveLock_1 = false;
        return
    }
    var num, TempSpeed = Speed_1, TempSpace = Space_1;
    if (Math.abs(Comp_1) < PageWidth_1 / 2) {
        TempSpace = Math.round(Math.abs(Comp_1 / Space_1));
        if (TempSpace < 1) {
            TempSpace = 1
        }
    }
    if (Comp_1 < 0) {
        if (Comp_1 < -TempSpace) {
            Comp_1 += TempSpace;
            num = TempSpace
        } else {
            num = -Comp_1;
            Comp_1 = 0
        }
        GetObj('ISL_Cont_1').scrollLeft -= num;
        setTimeout('CompScr_1()', TempSpeed)
    } else {
        if (Comp_1 > TempSpace) {
            Comp_1 -= TempSpace;
            num = TempSpace
        } else {
            num = Comp_1;
            Comp_1 = 0
        }
        GetObj('ISL_Cont_1').scrollLeft += num;
        setTimeout('CompScr_1()', TempSpeed)
    }
}

function picrun_ini() {
    GetObj("List2_1").innerHTML = GetObj("List1_1").innerHTML;
    GetObj('ISL_Cont_1').scrollLeft = fill_1 >= 0 ? fill_1 : GetObj('List1_1').scrollWidth - Math.abs(fill_1);
    GetObj("ISL_Cont_1").onmouseover = function () {
        clearInterval(AutoPlayObj_1)
    }
    GetObj("ISL_Cont_1").onmouseout = function () {
        AutoPlay_1()
    }
    AutoPlay_1();
}

var speed = 30
var colee_left2 = document.getElementById("colee_left2");
var colee_left1 = document.getElementById("colee_left1");
var colee_left = document.getElementById("colee_left");
colee_left2.innerHTML = colee_left1.innerHTML
function Marquee3() {
    if (colee_left2.offsetWidth - colee_left.scrollLeft <= 0)
        colee_left.scrollLeft -= colee_left1.offsetWidth
    else {
        colee_left.scrollLeft++
    }
}
var MyMar3 = setInterval(Marquee3, speed)
colee_left.onmouseover = function () {
    clearInterval(MyMar3)
}
colee_left.onmouseout = function () {
    MyMar3 = setInterval(Marquee3, speed)
}
 */